/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>Project: javase2203 - VolatileTest
 * <p>Powered by webrx On 2022-08-09 09:49:01
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class VolatileTest {
    int count = 0;
    synchronized void  m() {
        for(int i=0; i<10000; i++) count++;
    }
    public static void main(String[] args) {
        VolatileTest t = new VolatileTest();
        List<Thread> threads = new ArrayList<>();
        for(int i=0; i<10; i++) {
            threads.add(new Thread(t::m, "thread-"+i));
        }
        threads.forEach((o)->o.start());
        threads.forEach((o)->{
            try {
                o.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        System.out.println(t.count);
    }
}
